package com.yaorange.api;


import com.yaorange.common.core.domain.AjaxResult;
import com.yaorange.common.core.domain.entity.SysDictData;
import com.yaorange.system.service.ISysDictDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/api/common")
public class NjtCommon {


    @Autowired
    private ISysDictDataService sysDictDataService;

    @ApiOperation("获取字典值")
    @GetMapping("/queryDictType")
    public AjaxResult queryDictType(@RequestParam(value = "dictType") String Type) {
        SysDictData sysDictData = new SysDictData();
        sysDictData.setDictType(Type);
        List<SysDictData> list = sysDictDataService.selectDictDataList(sysDictData);
        return AjaxResult.success(list);
    }

    @ApiOperation("返回img")
    @PostMapping("/upload")
    public AjaxResult upload(@RequestParam("file") MultipartFile file) {
        return AjaxResult.success(file);
    }


    @ApiOperation("返回img")
    @GetMapping("/queryDictLabelByValue")
    public AjaxResult queryDictLabelByValue(@RequestParam("dictType") String dictType,
                                            @RequestParam("dictValue") String dictValue) {
        String label = sysDictDataService.selectDictLabel(dictType, dictValue);
        return AjaxResult.success(label);
    }

}
